
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ page import="java.util.ArrayList,
                 java.util.Iterator,
                 com.scalar.ScalarException,
                com.scalar.chiptrack.commons.SessionKeys,
                com.scalar.chiptrack.operations.process.BinSetup,
                com.scalar.chiptrack.operations.process.dao.BinSetupDAO,
                com.scalar.chiptrack.utils.ConfigManager"%>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<!--chiptrack:checkLogon sourcePage="/jsp/operations/bins_substitutable.jsp"/-->
<chiptrack:checkLogon sourcePage="/baseProductList.do"/>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<html:html locale="true">

<HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href='<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css' type='text/css' rel='stylesheet'>

<SCRIPT>
function saveSubstitutableBins() {
    document.testBinSubstituteForm.submit();
}

function back(){
      window.location = '<%=chipTracContext%>/processView.do?action=true&productID='+document.testBinSubstituteForm.baseProductId.value;
}
</SCRIPT>
</HEAD>
<BODY bgColor='#ffffff' leftMargin='0' topMargin='0' marginheight='0' marginwidth='0'>

<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
	<TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<!-- Side Navigation start -->

<%@ include file="/jsp/operations/operations_menu.jsp" %>

	</TD>
<!-- end of the side navigations -->

<TD bgcolor="#ffffff">
<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">

<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>
<!-- from here your body starts -->

<center><span class="NArialW">Bin Substitution</span></center> <img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20>

<html:form name="testBinSubstituteForm" type="com.scalar.chiptrack.ChipTrackActionForm" action="/testBinSubstitute.do?action=save">
<!-- added by hareesh on 22nd September 2003 -->
<input type='hidden' name='baseProductId' value='<%= session.getAttribute ("baseProductId") %>' >

    <table border="0" width="90%" align=right>

      <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=15></td></tr>
      <tr><td colspan=5>
      <table border="0" width="90%" bordercolor="#FFFFFF">
	      <tr>
	   <td width="30%" bgcolor="#993333" align="center"><font class="NArialL"><font color="#FFFFFF">Bin
	          Number</font></td>
	        <td width="70%" bgcolor="#993333" align="center"><font class="NArialL"><font color="#FFFFFF">Substitutable Bins</font></font></td>
	      </tr>


            <%
              /*  int processStepId = Integer.parseInt ((String) session.getAttribute ("processStepId"));
                int oldProcessStepId = Integer.parseInt ((String) session.getAttribute ("oldProcessStepId"));
                ArrayList substitutableBinList = null;
                try {
                    if (oldProcessStepId != -1) {
                        substitutableBinList = BinSetupDAO.loadSubstituableBins (oldProcessStepId);
                    }
                    else {
                        substitutableBinList = BinSetupDAO.loadSubstituableBins (processStepId);
                    }

                    request.setAttribute ("substitutableBinList", substitutableBinList);
                }
                catch (ScalarException se) {
                    System.out.println ("Exception while loading Substitutable Bin information: " + se.getRootCause());
                }
					*/
				ArrayList substitutableBinList = (ArrayList)request.getAttribute("substitutableBinList");
                if (substitutableBinList == null) substitutableBinList = new ArrayList();

                ArrayList goodBins = (ArrayList) session.getAttribute (SessionKeys.GOOD_BINS);              
                int binSize = goodBins.size();
                String partNumber = null;
                String binNumber = null;
                BinSetup bin = null;
                BinSetup bin2 = null;

                String cellColor[] = {"#CCCCCC", "#FFFFEE"};

                for (int i=0; i<binSize; i++) {
                    bin = (BinSetup)goodBins.get (i);
            %>
                    <tr>
                    <td width="20%" align="center" bgcolor='<%=cellColor[i%2]%>'><font class="NArialL"><%=bin.getBinNo()%></font></td>
                    <td width="40%" align="center" bgcolor='<%=cellColor[i%2]%>'>
            <%
                    String binPartNumber = null;
                    String bin2PartNumber = null;

                    for (int j=0; j<binSize; j++) {
                        if (i > j) {
                            bin2 = (BinSetup)goodBins.get (j);
                            
                            binPartNumber = bin.getPartNumber();
                            bin2PartNumber = bin2.getPartNumber();
            %>
                    <input type="checkbox" name='<%=binPartNumber%>' value='<%=bin2PartNumber%>' <%if (substitutableBinList.contains (binPartNumber+"|"+bin2PartNumber)) out.print ("checked");%>  ><font class="NArialL"><%=bin2.getBinNo()%>&nbsp;&nbsp;</font>
            <%
                        }   // if (i > j)
                    }   // for (int j=0; j<binSize; j++)
            %>
                </tr>   
            <%
                }   // for (int i=0; i<binSize; i++)
            %>


    	  <tr><td colspan=3>&nbsp;</td></tr>
		  <tr>
		    <td align=center colspan=3>
                <!-- changed by hareesh on 22nd September 2003 -->
                 <!--a href="javascript:saveSubstitutableBins()"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif"></a-->
                 <chiptrack:restrictedLink functionality='<%=Functionality.PRODUCT_SETUP%>' action='<%=User.USER_ACTION_MODIFY%>' href='javascript:saveSubstitutableBins();' onmouseover="window.status='Click here to save this Bin Substitution';return true" onmouseout="window.status='';return true">
                  <img border='0' src='<%=chipTracContext%>/jsp/includes/images/next.gif'></chiptrack:restrictedLink>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                  <!--img border="0" src="<%=chipTracContext%>/jsp/includes/images/cancel.gif"></a-->
                  <chiptrack:restrictedLink functionality='<%=Functionality.PRODUCT_SETUP%>' action='<%=User.USER_ACTION_MODIFY%>' href='javascript:back();' onmouseover="window.status='Click here to go back to Process View';return true" onmouseout="window.status='';return true">
                  <img border='0' src='<%=chipTracContext%>/jsp/includes/images/cancel.gif'></chiptrack:restrictedLink></a>
     		</td></tr>
	    </table>

      </td></tr>
    </table>

</html:form>

<!-- till here -->
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>

<!-- Footer starts here -->

<%@ include file="/jsp/includes/footer.jsp" %>

<!-- footer end here -->

</body>
</html:html>
